@extends('layout.user')

@section('userContent')

<div class="col-sm-6 col-sm-offset-1">

  <h1 class="page-header" style="margin-top: 0"><small>修改个人设置</small></h1>

  {{Form::open(['action'=>'UserController@postSetting', 'role'=>'form', 'class'=>'form-horizontal'])}}

      <div class="form-group">
        <label class="col-sm-2 control-label text-right" for="email">电子邮件</label>
        <div class="col-sm-10">
          <input type="email" name="email" id="email" class="form-control" value="{{$curr_user->email}}" disabled />
        </div>
      </div>

      <div class="form-group">
        <label class="col-sm-2 control-label text-right" for="real_name">真实姓名</label>
        <div class="col-sm-10">
        @if( $curr_user->real_name )
          <input type="text" name="real_name" id="real_name" class="form-control" value="{{$curr_user->real_name}}" disabled/>
        @else
          <input type="text" name="real_name" id="real_name" class="form-control" placeholder="请输入真实姓名, 输入一次后不可更改！" />
        @endif
        </div>
      </div>
      {{$errors->first('real_name', '<div class="alert alert-danger col-sm-offset-2 col-sm-10" role="alert">:message</div>')}}

      <div class="form-group">
        <label class="col-sm-2 control-label text-right" for="newPassword">修改密码</label>
        <div class="col-sm-10">
          <input type="password" name="newPassword" id="newPassword" class="form-control" value="{{Input::old('newPassword')}}" placeholder="输入新的密码"/>
        </div>
      </div>
      {{$errors->first('newPassword', '<div class="alert alert-danger col-sm-offset-2 col-sm-10" role="alert">:message</div>')}}

      <div class="form-group">
        <label class="col-sm-2 control-label text-right" for="newPassword_confirmation">确认密码</label>
        <div class="col-sm-10">
          <input type="password" name="newPassword_confirmation" id="newPassword_confirmation" class="form-control" value="{{Input::old('newPassword_confirmation')}}" placeholder="再次输入新的密码"/>
        </div>
      </div>
      {{$errors->first('newPassword_confirmation', '<div class="alert alert-danger col-sm-offset-2 col-sm-10" role="alert">:message</div>')}}

      <div class="form-group">
        <label class="col-sm-2 control-label text-right" for="identify_number">证件号</label>
        <div class="col-sm-10">
          <input type="number" name="identify_number" id="identify_number" class="form-control" value="{{Input::old('identify_number')}}" placeholder="输入学号或工作号"/>
        </div>
      </div>
      {{$errors->first('identify_number', '<div class="alert alert-danger col-sm-offset-2 col-sm-10" role="alert">:message</div>')}}

      <div class="form-group">
        <label class="col-sm-2 control-label text-right" for="role">用户类型</label>
        <div class="col-sm-10">
          <select class="form-control" value="{{$curr_user->role->id}}" name="role_id" id="role" disabled>
            <option selected >{{$curr_user->role->label}}</option>
          </select>
        </div>
      </div>

      <div class="form-group">
        <label class="col-sm-2 control-label text-right" for="unit_id">单位</label>
        <div class="col-sm-10">
          <select class="form-control" value="{{$curr_user->unit->id or '0'}}" name="unit_id" id="unit_id">
            <option value="0">请选择</option>
            @foreach($units as $curr_unit)
              @if( isset($curr_user->unit->id) && $curr_unit->id == $curr_user->unit->id )
                <option value="{{$curr_unit->id}}" selected>{{$curr_unit->unit_name}}</option>
              @else
                <option value="{{$curr_unit->id}}">{{$curr_unit->unit_name}}</option>
              @endif
            @endforeach
          </select>
        </div>
      </div>

      <div class="form-group">
        <label class="col-sm-2 control-label text-right" for="description">个人简介</label>
        <div class="col-sm-10">
          <textarea name="description" id="description" class="form-control" placeholder="这位童鞋很随意，什么也没有留下 o(╯□╰)o">{{$curr_user->description}}</textarea>
        </div>
      </div>

      <hr/>

      <div class="input-group" style="width: 60%; margin: auto">
        <div class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></div>
        <input type="password" name="password" id="password" class="form-control" placeholder="输入密码以确定修改" required/>
      </div>

      {{$errors->first('password','
      <div class="alert alert-warning" style="width: 60%; margin: auto" role="alert">
        <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        :message
      </div>')}}

      <div class="form-control-btn"><center>
        <button class="btn btn-warning" type="reset">重置</button>
        <button class="btn btn-success" type="submit">确认修改</button>
      </center></div>

  {{Form::close()}}

</div>

<div class="col-sm-2 col-sm-offset-1">
  <h2 class="page-header" style="margin-top: 0"><small>修改头像</small></h2>

  <div class="row">
    <div class="col-sm-12">
      <img src="/image/default-header.jpg" alt="头像" style="width: 90%"/>
    </div>

    <div class="class col-sm-12" style="margin-top: 1em">

      <input type="file" name="new_header" class="form-control"/>
      <button class="btn btn-primary btn-block" type="submit">上传新头像</button>
      <button class="btn btn-success btn-block">确定修改</button>

    </div>
  </div>
</div>

@stop